package bancosys.tec.persist.column.domain;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jmine.tec.persist.annotation.Alias;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Type;

import bancosys.tec.persist.bussobj.PersistableBusinessObject;
import bancosys.tec.persist.entities.domain.Filho;

@Entity
@Table(name = "WITH_COLUMN_RESTRICTIONS")
@Alias("COLREST")
@SequenceGenerator(name = "SEQ_COLREST", sequenceName = "SEQ_COLREST")
public class EntityWithColumnRestrictions extends PersistableBusinessObject {

    public static final int PRECISION = 8;

    public static final int SCALE = 4;

    public static final int LENGTH = 10;

    private int intP;

    private double doubleP;

    private BigDecimal bigDecimal;

    private String string;
    
    private Long id;
    
    private String lob;

    private Filho entity;

    /**
     * @return the id
     */
    @Id
    @Column(name = "COD_COLREST")
    @GeneratedValue(generator = "SEQ_COLREST")
    public Long getId() {
        return this.id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the intP
     */
    @Column(name = "INT", precision = PRECISION)
    public int getIntP() {
        return intP;
    }

    /**
     * @param intP the intP to set
     */
    public void setIntP(int intP) {
        this.intP = intP;
    }

    /**
     * @return the doubleP
     */
    @Column(name = "DOUBLE", precision = PRECISION, scale = SCALE)
    public double getDoubleP() {
        return doubleP;
    }

    /**
     * @param doubleP the doubleP to set
     */
    public void setDoubleP(double doubleP) {
        this.doubleP = doubleP;
    }

    /**
     * @return the bigDecimal
     */
    @Column(name = "BIG_DECIMAL", precision = PRECISION, scale = SCALE)
    public BigDecimal getBigDecimal() {
        return bigDecimal;
    }

    /**
     * @param bigDecimal the bigDecimal to set
     */
    public void setBigDecimal(BigDecimal bigDecimal) {
        this.bigDecimal = bigDecimal;
    }

    /**
     * @return the string
     */
    @Column(name = "STRING", length = LENGTH)
    public String getString() {
        return string;
    }

    /**
     * @param string the string to set
     */
    public void setString(String string) {
        this.string = string;
    }

    @Lob
    @Type(type = "org.hibernate.type.TextType")
    @Column(name = "LOB")
    public String getLob() {
        return lob;
    }

    public void setLob(String lob) {
        this.lob = lob;
    }

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "COD_ENTITY")
    @Cascade({ CascadeType.ALL, CascadeType.DELETE_ORPHAN })
    @ForeignKey(name = "FK_ENTITY_FILHO")
    public Filho getEntity() {
        return entity;
    }

    public void setEntity(Filho entity) {
        this.entity = entity;
    }
}
